package main

import (
	"math"
	"sort"
)

func toInt(str string) int {
	return int(str[0]-'0')*600 + int(str[1]-'0')*60 + int(str[3]-'0')*10 + int(str[4]-'0')
}

func findMinDifference(timePoints []string) int {
	if len(timePoints) > 1440 || len(timePoints) < 2 {
		return 0
	}
	points := make([]int, len(timePoints))
	for i, point := range timePoints {
		points[i] = toInt(point)
	}
	sort.Slice(points, func(i, j int) bool {
		return points[i] < points[j]
	})
	minDiff := math.MaxInt32
	for i := 1; i < len(points); i++ {
		diff := points[i] - points[i-1]
		if diff == 0 {
			return 0
		}
		if diff < minDiff {
			minDiff = diff
		}
	}
	diff2 := 1440 + points[0] - points[len(points)-1]
	if diff2 < minDiff {
		return diff2
	}
	return minDiff
}

func main() {
	input := []string{"23:59", "00:00"}
	println(findMinDifference(input))
}
